home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / deleteReferenceObject.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  2.9 KB  |  76 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. global proc deleteReferenceObject()
  18. //
  19. // Description
  20. //        Looks at the selection list for the first piece of
  21. //        geometry and then proceeeds to:
  22. //                delete the referenceObject for each
  23. //                surface under the selectedObject.
  24. //
  25. {
  26.     // Get the relevant selected objects (transforms or geometryShapes)
  27.     string $selectedObjects[] = `ls -sl -type transform -type geometryShape`;
  28.  
  29.     if (size($selectedObjects) >= 1) {
  30.  
  31.         // Get the geometryShapeNodes for the first selected object.
  32.         string $originalShapeNodes[] = 
  33.             `ls -sl -dagObjects -type geometryShape $selectedObjects[0]`;
  34.         
  35.         if (size($originalShapeNodes) >= 1) {
  36.             // There is at least one geometryShape node so proceed
  37.  
  38.             // Iterate through all the shape nodes
  39.             for ($shapeNode in $originalShapeNodes) {
  40.     
  41.                 // If referenceObject attribute is connected, find out the
  42.                 // node it is connected to and delete it.
  43.                 string $connectedNode[] = 
  44.                     `listConnections -shapes true ($shapeNode + ".referenceObject")`;
  45.  
  46.                 if (size($connectedNode) == 1) {
  47.                     int $interHist = `getAttr ($connectedNode[0] +
  48.                                         ".intermediateObject")`;
  49.                     //
  50.                     // If the reference object is an intermediate object
  51.                     // (ie, the undeformed original shape), then just
  52.                     // break the connection.
  53.                     // Otherwise, delete the reference shape.
  54.                     //
  55.                     
  56.                     // We used to try to optimize by not making a reference object
  57.                     // but connecting to an undeformed upstream node.  If we load
  58.                     // an old file (2.0) that has such a connection and the user
  59.                     // tries to "delete reference object" we will warn the user
  60.                     // and break the connection.
  61.                     //
  62.                     if ($interHist) {
  63.                         string $warningMsg = ("Reference object " + $connectedNode[0] + " is an intermediate object.  This object will no longer be a reference object for " + $shapeNode + " but it will not be deleted.");
  64.                         warning($warningMsg);
  65.                         disconnectAttr ($connectedNode[0] + ".message")
  66.                             ($shapeNode + ".referenceObject");
  67.  
  68.                     } else {
  69.                         delete $connectedNode[0];
  70.                     }
  71.                 }
  72.             }
  73.         }
  74.     }
  75. }
  76.